package com.education.platform.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.education.platform.common.Result;
import com.education.platform.dto.parent.ParentQueryDTO;
import com.education.platform.service.ParentService;
import com.education.platform.vo.parent.ParentVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "家长管理", description = "家长信息查询、管理等接口")
@RestController
@RequestMapping("/api/parent")
@RequiredArgsConstructor
@SaCheckLogin
public class ParentController {

    private final ParentService parentService;

    @Operation(summary = "管理员查询家长列表")
    @GetMapping("/admin/list")
    public Result<Map<String, Object>> adminGetParents(ParentQueryDTO queryDTO) {
        Map<String, Object> result = parentService.adminGetParents(queryDTO);
        return Result.success(result);
    }

    @Operation(summary = "管理员获取家长详情")
    @GetMapping("/admin/{id}")
    public Result<ParentVO> adminGetParentDetail(@PathVariable Long id) {
        ParentVO parent = parentService.adminGetParentDetail(id);
        return Result.success(parent);
    }

    @Operation(summary = "管理员更新家长状态")
    @PostMapping("/admin/{id}/status")
    public Result<Void> adminUpdateParentStatus(
            @PathVariable Long id,
            @RequestParam String status
    ) {
        parentService.adminUpdateParentStatus(id, status);
        return Result.success();
    }
}

